
import React from "react";
import {Form, Select} from "antd";

class FormMulSelect extends React.Component{
    constructor(props) {
        super(props);
        this.state={}
    }

    render() {
        const {getFieldDecorator} = this.props.form;
        /**
         * options 传一个对象 {key:value}
         */
        const {label,field,initialValue,rules,options,showSearch,placeholder,allowClear} = this.props;
        const { Option } = Select;
        return (
            <Form.Item label={label ? label : "下拉选择框(多选)"}>
                {getFieldDecorator(field ? field : "default_mul_dropdown_list", {initialValue: initialValue ? initialValue : [],rules: rules ? rules : []})(
                    <Select
                        showSearch={showSearch ? showSearch : true}
                        placeholder={placeholder ? placeholder : "请选择..."}
                        allowClear={allowClear ? allowClear : true}
                        mode="multiple"
                    >
                        {
                            Object.keys(options ? options : {}).map(key => (
                                <Option key={key} value={key}>{options[key]}</Option>
                            ))
                        }
                    </Select>
                )}
            </Form.Item>
        );
    }
}

export default FormMulSelect;
